package com.yupi.springbootinit.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yupi.springbootinit.model.entity.SalesOrderItem;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 订单明细Mapper（XML方式）
 */
@Mapper
public interface SalesOrderItemMapper extends BaseMapper<SalesOrderItem> {

    /**
     * 根据订单ID查询明细列表
     */
    List<SalesOrderItem> selectByOrderId(@Param("orderId") Long orderId);

    /**
     * 根据订单号查询明细列表
     */
    List<SalesOrderItem> selectByOrderNumber(@Param("orderNumber") String orderNumber);

    /**
     * 批量查询订单明细（解决N+1问题）
     */
    List<SalesOrderItem> selectByOrderIds(@Param("orderIds") List<Long> orderIds);

    /**
     * 软删除订单的所有明细
     */
    int deleteByOrderId(@Param("orderId") Long orderId);
}